package example.treemap;

import java.util.*;
import java.util.stream.Collectors;

public class TreeMapUse {
    public static void main(String[] args) {
        TreeMap<Student, String> treeMap = new TreeMap<>((o1, o2) -> {
            if (o1.getAge() == o2.getAge()) {
                return 0;
            } else if (o1.getAge() > o2.getAge()) {
                return 1;
            } else {
                return -1;
            }

        });

//        Collections.synchronizedList()
        treeMap.put(new Student("444", 444), "1");
        treeMap.put(new Student("555", 555), "1");
        treeMap.put(new Student("111", 111), "1");
        treeMap.put(new Student("222", 222), "1");
        treeMap.put(new Student("333", 333), "1");
        Set<Student> students = treeMap.keySet();
        Iterator<Student> iterator = treeMap.keySet().iterator();
        iterator.remove();
        int size = treeMap.size();
        System.out.println(size);
        System.out.println(students);

    }
}